package uc108.com.jetpackdemo.viewmodel;

import android.app.Activity;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProviders;

import uc108.com.jetpackdemo.bean.SelectInfo;

public  class SelectInfoViewModel extends ViewModel {

    private MutableLiveData<SelectInfo> mutableLiveData = new MutableLiveData<>();

    public void setData(SelectInfo info){
        mutableLiveData.setValue(info);
    }

    public LiveData<SelectInfo> getData(){
        return mutableLiveData;
    }

    static SelectInfoViewModel instance;

    public static SelectInfoViewModel getInstance(Fragment activity){
        if (instance == null){
            instance = ViewModelProviders.of(activity).get(SelectInfoViewModel.class);
        }
        return instance;
    }
}
